Repository navigation
fix(plugin-auth)!: a cloud-managed runtime keeps email and password off when its deployment declares it off - #38028
objectstack-fleet[bot] wants to merge 5 commits into
Conversation
…f when its deployment declares it off Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
…untime; changeset Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
…loor suite Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
📓 Docs Drift CheckThis PR changes 1 package(s): 11 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 6 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 415782fc25b040d42da7fec6651650ae450ab98d && git checkout 415782fc25b040d42da7fec6651650ae450ab98d
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin b4921982a0fd09f763d61adf4d4315698ef493ad 5dd302a33d1a9cc64c206f477814013f09852119 && git checkout -B drift-repro b4921982a0fd09f763d61adf4d4315698ef493ad && git merge --no-ff 5dd302a33d1a9cc64c206f477814013f09852119
node scripts/docs-audit/affected-docs.mjs --json b4921982a0fd09f763d61adf4d4315698ef493ad
|
|
repo:objectstack#6 · hotlong · session_01Q4EjjQkY5yXZrN9BEA3rEK Contract reviewServed-tier: First round on this PR. Inputs: card #34174, triage 7211578688, claim 7222972851, dev report 7224276022 (its conclusions not adopted), the PR body's declaration lines, ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentOwed on the narrowing face (M1); judged over the whole diff outside the changeset.
M1 (must-fix): the declaration line is wrong in the PR body and the changeset.
S1 (should-fix): the Google leg of the floor trusts a batch value the runtime will not apply.
Nits, none with an effect on correctness or the contract:
Must-fix: M1. Should-fix: S1. Implemented-by: VERDICT: FAIL |
…assword as a way in; docs state the managed case Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
…banner and ADR-0087 disposition Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
|
repo:objectstack#6 · hotlong · session_01Q4EjjQkY5yXZrN9BEA3rEK Contract reviewServed-tier: Delta round by the reviewer of record 7224378765 (FAIL at ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentFindings of the first record, at this head: M1 (must-fix): closed.
S1 (should-fix): closed.
Nits, none with an effect on correctness or the contract:
No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#6 · hotlong · session_01Q4EjjQkY5yXZrN9BEA3rEK 维护者速读
席位意见:首轮契约审核 FAIL(声明应为收窄 + 一处判定漏洞),返工后全部关闭;CI 全绿;新发现的设置页显示问题已立卡 #38029。建议批准。 席位核对 — ACCEPT · repo:objectstack#6 · head
|
|
repo:objectstack#6 · hotlong · session_01Q4EjjQkY5yXZrN9BEA3rEK Review requested: this narrowing PR ( Records at head
|
Fixes #34174
Clause-②: yes (narrowing) — narrowed: on a cloud-managed runtime (
OS_CLOUD_MANAGED=1) whose deployment declaresemailAndPassword.enabled: false, an auth settings save (PUT /api/settings/auth) that changesemail_password_enabledto a value that reads on answers400 SETTINGS_VALIDATIONand saves nothing in the batch, where it saved; a stored value that reads on is no longer applied there; and there a Google change no longer counts email and password as a way in. Widened: on that runtime, a save that turnsemail_password_enabledoff or clears it answers200and saves without the sign-in method floor, where the floor refused it400 SETTINGS_VALIDATION; the field error can carryconstraint: { cloudManaged: true, declaredEmailPassword: false }; amanagedEmailPasswordcopy key in all 11 locales.Metadata-protocol: none
Skills-docs: none — no skill under
skills/**teaches the auth settings save or the email and password switch;content/docs/deployment/self-hosting.mdxandcontent/docs/permissions/sso.mdxgain the cloud-managed case in this change.维护者速读
What changes
On a cloud-managed runtime (
isCloudManaged()) whose deployment declaredemailAndPassword.enabled: false, email and password stays off whatever theauthsettings hold. Two places, both inplugin-auth:bindAuthSettings,auth-plugin.ts). A storedauth.email_password_enabledthat reads on is not applied there, sogetPublicConfig().emailPassword.enabled(whatGET /api/v1/auth/configserves) keeps answeringfalse. Said once aterrorwith the remedy (clear the setting), the same level this pass uses for the audience settings it does not apply. AnOS_AUTH_EMAIL_PASSWORD_ENABLEDvalue (source: 'env') is the deployment's own declaration and still applies.sign-in-method-floor.ts). The write predicate onemail_password_enabled(the sign-in floor's; the settings service keeps one predicate per key) refuses a save of a value that reads on there:400 SETTINGS_VALIDATION,invalid_valueat the key, a new localized sentencemanagedEmailPasswordin all eleven settings locales, constraint{ cloudManaged: true, declaredEmailPassword: false }. Any other save of the key there (off, or a clear) passes, and is no longer judged by the floor: the host holds it off either way, so it removes no way in, and it is how a row stored on is put right. A Google change judged by the floor there reads email and password as off whatever the same save sets it to (contract review S1): atruethat is no change asks no predicate at its own key, and the runtime would not apply it.self-hosting.mdx(the sign-in floor section) andsso.mdx(the direct sign-inoffsection) state the cloud-managed case.Why both, chosen contract-first. The card offers "refuse the save" or "do not apply the key". Measured on
main(below), the save door alone cannot close it: with nothing stored, the key resolves to the manifest defaulttrue, so the settings service sees a save oftrueas no change, asks no predicate, and stores the row, which the pass then applied. Rows stored before this change are not reached by a save door either. So the guarantee is the settings pass not applying the key on such a runtime, and the save door is the loud refusal wherever the settings service does ask (a change from a storedfalse). Neither half adds a tolerant fallback in a consumer: the deployment's declaration is the authority, and the store is refused, not reinterpreted.Admin update-user (the card's last section). better-auth 1.7.12's
POST /admin/update-userrefusesdata.passwordon every deployment (dist/plugins/admin/routes.mjs,PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER, 400) before any write. No fix needed; a pin incloud-managed.test.tsholds it on a managed runtime (400 with that code, the member's hash unchanged, the identity-provider user still without a credential), so a vendor upgrade that starts accepting the key reds here.Self-hosted deployments, and managed ones that declared email and password on, are unchanged (two CONTROL cases).
Read first (by risk):
packages/plugins/plugin-auth/src/auth-plugin.ts, theemail_password_enabledbranch ofbindAuthSettings: the skip condition (enabled && source !== 'env' && emailPasswordHeldOffByHost(...)) and the once-onlyerror.packages/plugins/plugin-auth/src/sign-in-method-floor.ts, the new first branch ofsignInMethodFloorPredicate: it returns before the floor for every save of that key on such a runtime.packages/plugins/plugin-auth/src/sign-in-method-floor.test.ts, the new lastdescribe.Tests
describeinsign-in-method-floor.test.ts(realAuthPlugin, realSettingsServicewith the shipped auth manifest, real settingsPUTroute), eight cases: a stored value that reads on is not applied and is said once; a row stored before boot is not applied; turning it on is refused at the save door (envelope400+SETTINGS_VALIDATION, fieldinvalid_value, the zh-CN sentence, nothing in the batch written); clearing a row stored on passes; the env declaration still applies;{ email_password_enabled: true, google_enabled: false }with Google the last way in is refused atgoogle_enabled; CONTROL self-hosted; CONTROL managed with email and password declared on.cloud-managed.test.ts: admin update-user withdata.passwordon a managed runtime.Premise, measured on main 4af32b9 before any edit
A probe test (deleted afterwards) booted
AuthPluginwithemailAndPassword: { enabled: false }underOS_CLOUD_MANAGED=1over a realSettingsService:So
getPublicConfig().emailPassword.enabledwentfalse→trueon a save oftrue, which no predicate was asked about, and turning it back off was then refused by the sign-in floor.Ablation (each leg through scripts/ablation-replace.mjs, restored to HEAD, git diff HEAD empty)
if (!emailPasswordHeldOff)→if (true)): 2 failed / 5 passed of the new describe (the two "not applied" cases).if (key === 'email_password_enabled' && emailPasswordHeldOffByHost(deps))→if (false)): 2 failed / 5 passed (the refusal case, and the clear case, which the floor then refuses).localOffered && !emailPasswordHeldOffByHost(deps)→localOffered && true): 1 failed / 7 passed (the Google case).Verification
Local runs at the final head
All at final head
5dd302a3.pnpm --filter @objectstack/plugin-auth typecheck: passed (tsc --noEmit, the examples project,check:test-typecheckOK).pnpm --filter @objectstack/plugin-auth test: Test Files 295 passed (295), Tests 6298 passed, 10 skipped (6308).pnpm --filter @objectstack/dogfood testafter building its dependency closure, under the verify lock): Test Files 490 passed, 3 skipped (493); Tests 4144 passed, 68 skipped (4212); lock verdict command-exit 0.node scripts/pm/dispatch-gates.mjs --commands, 110 with the docs paths):--ranreconciliation 110 derived, 107 run with exit 0, 3 NOT MEASURED (exit 3, prerequisite):node scripts/check-plugin-teardown-shape.mjs --self-test(checker-health only; its pinned fixture needs an unshallowed clone),pnpm check:dual-build-cjs-loadsandpnpm --filter @objectstack/spec run check:skill-examples(each reads built output for packages outside the closure built here).check:dts-closureandcheck:type-check-debtfirst read a tree mid-rebuild / waited on this run's own lock, and re-ran green. Families CI runs are read from this PR's check-runs, not re-run here.Two-minute check:
pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/sign-in-method-floor.test.ts -t 'cloud-managed runtime keeps'shows 8 passed.Acceptance notes
auth.email_password_enabledas the manifest default (true,source: default) on any deployment that declared email and password off, self-hosted included, while the runtime runs it off. On a managed runtime a re-save of that default is stored and not applied (said aterror). It is not changed here.Generated by Claude Code